﻿using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using SportsStore.Domain.Abstract;
using SportsStore.WebUI.Models;

namespace SportsStore.WebUI.Controllers
{
    public class NavController : Controller
    {
        private ICategoryRepository repositoryCat;

        public NavController(ICategoryRepository catRepo)
        {           
            repositoryCat = catRepo;
        }
        
        public ViewResult Menu(string category = null)
        {
            ViewBag.SelectedCategory = category;

            IEnumerable<string> categories = repositoryCat.Categories
            .Select(x => x.Description)
            .Distinct()
            .OrderBy(x => x);
            return View(categories);


        }
    }
}